package com.sky.controller.user;

import com.sky.dto.SetmealDTO;
import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags = "C端-套餐浏览接口")
@RequestMapping("/user/setmeal")
@RestController("userSetmealController")
public class SetmealController {

    @Resource
    private SetmealService setmealService;

    @ApiOperation("根据分类ID查询套餐列表")
    @GetMapping("/list")
    public Result<List<SetmealVO>> listCategoryIdWithSetmeal(Long categoryId){
        log.info("查询套餐列表,{}", categoryId);
        List<SetmealVO> setmealVOList = setmealService.listCategoryIdWithSetmeal(categoryId);
        return Result.success(setmealVOList);
    }

    @ApiOperation("根据套餐id查询包含的菜品")
    @GetMapping("/dish/{id}")
    public Result<List<DishItemVO>> listSetmealById(@PathVariable("id") Long setmealId){
        log.info("查询套餐关联的菜品信息, {}", setmealId);
        List<DishItemVO> setmealDishes = setmealService.listSetmealByIdWithSetmealDish(setmealId);
        return Result.success(setmealDishes);
    }
}
